package unit2;

import java.util.Arrays;
import java.util.Random;

public class Ex2_18_ArrayDemo {
    public static void main(String[] args) {
        int num[] = new int[10];
        Random random = new Random(); //创建随机数对象
        for (int i = 0; i < num.length; i++) {
            num[i] = random.nextInt(100); //获取100以内整型随机数
            System.out.print(num[i] + "\t");
        }
        Arrays.sort(num); // 对数组进行排序
        System.out.println("\n排序之后----------------");
        for (int i = 0; i < num.length; i++) {
            System.out.print(num[i] + "\t");
        }
        if (Arrays.binarySearch(num, 85) > 0) //查找关键字85
            System.out.println("\n数组中包含关键字：85");
        else
            System.out.println("\n数组中不包含关键字：85");
    }
}
